//组件渲染顺序函数
import { onUnmounted, ref } from 'vue'
export function useDefer(maxCount = 100) {
  const frameCount = ref(1)
  let refId
  function updateFrameCount() {
    requestAnimationFrame(() => {
      frameCount.value++
      if (frameCount.value > maxCount) return
      updateFrameCount()
    })
  }
  onUnmounted(() => {
    cancelAnimationFrame(refId)
  })
  updateFrameCount()
  return function (n) {
    return frameCount.value >= n
  }
}
